﻿<Page
    x:Class="Cookbook.Views.RecipeDetailView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Cookbook.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    xmlns:vm="using:Cookbook.ViewModels"
    mc:Ignorable="d">

  <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
      <RowDefinition Height="140" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="120" />
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

<Button x:Name="backButton" Margin="39,59,39,0"
                    Style="{StaticResource NavigationBackButtonNormalStyle}"
                    VerticalAlignment="Top" 
        Tapped="backButton_Tapped"/>

    <TextBlock Text="{Binding Recipe.Title}" 
                Style="{StaticResource HeaderTextBlockStyle}" 
                TextWrapping="NoWrap" VerticalAlignment="Bottom" 
                Grid.Column="1" Margin="0,0,30,40"/>

    <Grid Grid.Column="1" Grid.Row="1">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="2*" />
        <ColumnDefinition Width="3*" />
      </Grid.ColumnDefinitions>

      <Image Source="{Binding Recipe.ImagePath}" Stretch="UniformToFill"/>

      <StackPanel Orientation="Vertical" Grid.Column="1" Margin="30,0">
        <ItemsControl ItemsSource="{Binding Recipe.Ingredients}">
          <ItemsControl.ItemTemplate>
            <DataTemplate>
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="50" />
                  <ColumnDefinition Width="70" />
                  <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <TextBlock Text="{Binding Amount}" Grid.Column="0" FontSize="16"/>
                <TextBlock Text="{Binding Unity}" Grid.Column="1" FontSize="16"/>
                <TextBlock Text="{Binding Title}" Grid.Column="2" FontSize="16"/>
              </Grid>
            </DataTemplate>
          </ItemsControl.ItemTemplate>
        </ItemsControl>

          <TextBlock Text="{Binding Recipe.Instructions}"  FontSize="20"
                            Margin="0,30,0,0" TextWrapping="Wrap"/>
      </StackPanel>
    </Grid>
  </Grid>
</Page>

